Partition
iconbar
***
1
0
6
Shortcut to disk partition
 SPROW 1997
1.15 (27-Apr-1997)
1
***
***
***
***
***
***

iconmenu%
Partition
...Info    !
...Setup...&open_setup_box

@

click_buttons
window%,icon%,button%
10
  :
  path$(csbutton%)=READICON(setup,pathbox%)
  name$(csbutton%)=READICON(setup,namebox%)
  :
  IFicon%=0 ORicon%=1 ORicon%=2 ORicon%=3 THEN
    SETICON(setup,pathbox%,path$(icon%))
    SETICON(setup,namebox%,name$(icon%))
    csbutton%=icon%
  ENDIF
  :
  IFicon%=savebutton% THEN
    IFFNfindvalid=-1 THEN
      PROCaltericon(Grey)
      PROCerror("The partitions you have created have no paths associated with them")
    ELSE
      PROCaltericon(Yellow)
      F=OPENOUT"<ObeyTask$Dir>.Setup"
      FORx%=0TO3:PRINT#F,path$(x%):PRINT#F,name$(x%):NEXT
      CLOSE#F:CLOSEWINDOW(setup)
      partition%=csbutton%
    ENDIF
  ENDIF
  SETICON(-2,iconh%,name$(csbutton%))
ENDPROC


define_variables
***
1
   REM Make an array for the 4 supported drives
   DIMpath$(3):DIMname$(3)
   REM Some buttons and stuff
   namebox%=10:pathbox%=12:savebutton%=13:ignorebutton%=4:setupbutton%=1
   csbutton%=0:REM Tag of the currently selected button if "Setup" is open
   partition%=0:REM Tag of the currently selected partition #
   REM Save some memory for error buffers and call blocks
   DIM wimperror% 256
   DIM block% 16
   REM And some icon names
   Grey=0:Yellow=1
   :
   REM Put something in each array element at least
   FORx%=0TO3:path$(x%)="ADFS::":name$(x%)=CHR$(67+x%)+":":NEXT
   :
   F=OPENIN"<ObeyTask$Dir>.Setup"
   IFF<>0 THEN
     LOCAL ERROR
     ONERRORLOCALRESTOREERROR:PROCaltericon(Grey):PROCerror("The 'Setup' file for this application has been damaged"):name$(x%)="Broken":path$(x%)="Broken":PROCopen_setup_box:SETICON(-2,iconh%,name$(partition%)):ENDPROC
     FORx%=0TO3:INPUT#F,path$(x%):INPUT#F,name$(x%):NEXT:CLOSE#F
   ENDIF
   :
   IFFNfindvalid=-1 THEN   
     PROCaltericon(Grey)
     PROCerror("No settings have been made yet for 'Partition' so it cannot be used")
     SETICON(-2,iconh%,name$(partition%))
     PROCopen_setup_box
   ELSE
     partition%=FNfindvalid
     SETICON(-2,iconh%,name$(partition%))
   ENDIF
ENDPROC


open_the_partition
button%
4
   IFbutton%=4 THEN
    IFpath$(partition%)<>"ADFS::" THEN
      OSCLI"Filer_OpenDir "+path$(partition%) 
    ELSE
      IFFNfindvalid=-1 THEN
        PROCaltericon(Grey)
        PROCerror("No settings have been made yet for 'Partition' so it cannot be used")
      ELSE
        partition%=FNfindvalid
        SETICON(-2,iconh%,name$(partition%))
        OSCLI"Filer_OpenDir "+path$(partition%)
      ENDIF
    ENDIF
   ENDIF 
   IFbutton%=1 THEN
    old%=partition%
    REPEAT
    partition%=partition%+1
    IFpartition%>3 THENpartition%=0
    UNTILpath$(partition%)<>"ADFS::" ORpartition%=old%
   SETICON(-2,iconh%,name$(partition%))
   ENDIF
ENDPROC


open_setup_box
***
0
  OPENWINDOW(setup)
  SETICON(setup,namebox%,name$(csbutton%))
  SETICON(setup,pathbox%,path$(csbutton%))
ENDPROC


drop_image
file$,type%
5
   IFOPENQ(setup)=FALSE THENENDPROC
   SETICON(setup,pathbox%,file$)
   path$(csbutton%)=file$
ENDPROC


error
mssg$
0
   CLOSE#0
   SYS "Hourglass_Smash"
   title$="Message from Partition"
   button$="Understood"
   flags%=256+2048+8+16
   P%=wimperror%
   [OPT2:EQUD0:EQUSmssg$+CHR$0:]
   SYS "Wimp_ReportError",wimperror%,flags%,title$,,,button$
ENDPROC


FNfindvalid
***
0
   LOCAL partition%,found%
   found%=-1
   FORpartition%=0TO3
   IFpath$(partition%)<>"ADFS::" ANDpath$(partition%)<>"" THENfound%=partition%
   NEXT
=found%


altericon
state%
0
   OSCLI"IconSprites <Obey$Dir>.icon"+STR$(state%)
   REM This block describes 'no change' to iconh%
   !(block%+0)=-2
   !(block%+4)=iconh%
   !(block%+8)=0
   !(block%+12)=0
   REM Make call now,a side effect of which is that the sprite is refreshed
   SYS"Wimp_SetIconState",,block%
ENDPROC

@

